package com.tvein.sanguo.crowd.controller
{
	//flash
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.command.SimpleFabricationCommand;
	//custom
	import com.tvein.sanguo.crowd.view.CrowdMediator;
//
	public class CrowdJoin extends SimpleFabricationCommand implements ICommand
	{
		private var crowdMediator:CrowdMediator;
		
		override public function execute(notification:INotification) : void
		{
			crowdMediator = facade.retrieveMediator(CrowdMediator.NAME) as CrowdMediator;
			
			if (notification.getBody().getVariable("roleCMD"))
			{
				var jso:Object = JSON.parse(notification.getBody().getVariable("roleCMD").getStringValue());
				crowdMediator.crowdShell.roleAdd(notification.getBody().name, notification.getBody().getVariable("roleName").getStringValue(), notification.getBody().getVariable("roleImage").getIntValue(), jso);
			}
		}
	}
}